package com.yulang.security.result;

import com.alibaba.fastjson.JSONObject;
import lombok.Data;

@Data
public class Result {

    private Integer code;

    private String message;

    private Object data;


    public static Result ok() {
        Result result = new Result();
        result.setCode(200);
        result.setMessage("认证成功");
        return result;
    }

    public static Result ok(Object data) {
        Result ok = ok();
        ok.setData(data);
        return ok;
    }


    public static Result error() {
        Result result = new Result();
        result.setCode(401);
        result.setMessage("认证失败");
        return result;
    }
    public static Result error(String message) {
        Result error = error();
        error.setMessage(message);
        return error;
    }


    public String toJsonString() {
        return JSONObject.toJSONString(this);
    }



}
